<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Author" content="cjw">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
  <style>
	*{margin: 0; padding: 0;}
  </style>
 </head>
 <body>
	<script src="MyjsV0-8.js"></script>
	<script>
	var json = {code:1, name:"cjw", age:23, add:{city:"北海",}, order:[{id:1,}]};
	alert(json.code);
	var jj = new ObjectParseJSON().parseJSON(json);
	alert(jj instanceof JSONObject);
	for(var ii in jj.getKeySet()){
		alert(jj.getKeySet()[ii])
	}
	function ObjectParseJSON(){
		function parseJSONObject(object){
			var jsonObject = new JSONObject();
			for(var i in object){
				if(object[i] instanceof Array)
					jsonObject.put(i, parseJSONArray(object[i]));
				else 
					jsonObject.put(i, object[i]);
			}
			return jsonObject;
		}
		function parseJSONArray(object){
			var jsonArray = new JSONArray();
			var len = object.length;
			for(var i = 0; i < len; i++){
				jsonArray.add(parseJSONObject(object[i]));
			}
			return jsonArray;
		}
		this.parseJSON = function(object){
			var jsonObj;
			if(object instanceof Array) {
				jsonObj = parseJSONArray(object);
			}
			else if(object instanceof Object) {
				jsonObj = parseJSONObject(object);
			}	
			else {
				console.log("异常的数据：" + object);
			}
			return jsonObj;
		}
	}
	</script>
 </body>
</html>